package com.ljq.ioc.core;

import lombok.extern.slf4j.Slf4j;

/**
 * bean的实例，拥有三个基本属性：
 * 1. klass：所属的类
 * 2. object: 实例
 * 3. inject: 是否注入
 */
public class BeanDefinition {

    private Class<?> klass;
    private Object object;
    private boolean inject;

    public BeanDefinition() {
    }

    protected Class<?> getKlass() {
        return klass;
    }

    protected void setKlass(Class<?> klass) {
        this.klass = klass;
    }

    protected Object getObject() {
        return object;
    }

    protected void setObject(Object object) {
        this.object = object;
    }

    protected boolean isInject() {
        return inject;
    }

    protected void setInject(boolean inject) {
        this.inject = inject;
    }

    protected Object getPropertyObject() throws IllegalAccessException, InstantiationException {
        return klass.newInstance();
    }

    @Override
    public String toString() {
        return "BeanDefinition{" + "klass=" + klass + ", object=" + object + ", inject=" + inject + '}';
    }
}
